package com.jcl.cloud.services.login.controller;


import com.jcl.cloud.common.service.exception.JclApiException;
import com.jcl.cloud.common.service.exception.JclCrawlException;
import com.jcl.cloud.services.login.service.LoginTaskManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(
        value = {"/login-worker/api/v1"},
        produces = {"application/json"}
)
public class TaskController {

    @Autowired
    private LoginTaskManagerService loginTaskManagerService;


    @RequestMapping(
            value = {"/manager/tasks"},
            method = {RequestMethod.GET}
    )
    public void createTask(String crawlerId) throws JclApiException {

        System.out.println("获取到的crawlerId = " + crawlerId);

        try {
            this.loginTaskManagerService.createLoginTask(crawlerId);
        } catch (JclCrawlException e) {
            e.printStackTrace();
            throw new JclApiException();
        } finally {

        }
    }




}
